package com.xtf.mutids.controller;

import com.xtf.mutids.cache.AreaCache;
import com.xtf.mutids.datasource.DynamicDataSource;
import com.xtf.mutids.mapper.UserMapper;
import com.xtf.mutids.model.UserReqDto;
import com.xtf.mutids.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("muti-test")
public class TestController {
    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/getUserByAreaCodeAndUserId")
    public String test(@RequestBody UserReqDto userReqDto) {
        AreaCache.setAreaCode(userReqDto.getAreaCode());
        User user = userMapper.selectByPrimaryKey(userReqDto.getUserId());
        AreaCache.clearAreaCode();
        return user.getName();
    }
}
